/*
 * XYZTCircle.java
 *
 * Created on September 20, 2004, 6:42 PM
 */

package edu.temple.GUS.MMA.Neighborhoods;

/**
 *
 * @author  jeffleon
 */
public class XYZTCircle extends XYZTNeighborhood {

    private int radius;
    
    private boolean filter[][][][];

    /** Creates a new instance of XYZTCircle */
    public XYZTCircle( int r, int t) {

        super(r*2+1, r*2+1, r*2+1, t);
        radius = r;

        float distance;
        int kernelXCoord;
        int kernelYCoord;
        int kernelZCoord;
        
        kernelXCoord = r;
        kernelYCoord = r;
        kernelZCoord = r;
        
        // Create a spherical filter
        filter = new boolean[t][2*radius+1][2*radius+1][2*radius+1];
        
        for (int l=0; l< t; l++)
            for (int k=0; k<=2*radius; k++)
                for (int j=0; j<=2*radius; j++)
                    for (int i=0; i<=2*radius; i++)
                    {
                        distance = (float)Math.sqrt((k - kernelZCoord) * (k - kernelZCoord) + (j - kernelYCoord) * (j - kernelYCoord) + (i - kernelXCoord) * (i - kernelXCoord));
                        if ( distance <= (float)radius)
                            filter[l][k][j][i] = true;
                        else
                            filter[l][k][j][i] = false;
                    }
    }
    
    public int getRadius() { return radius; }    
    public void putRadius(int r) { radius = r; }
    public boolean getFilterElement(int x, int y, int z, int t) { return filter[t][z][y][x];}

}
